<h1>Youth <%= format("%03d", @youth.id) %></h1>

<p></p>

<%= link_to "Delete this youth", {:action => 'delete', :id => @youth.id}, :confirm => "Really delete youth? All related data like data collections and notes will be lost forever."  %>



<% form_tag :action => 'update', :id => @youth  do %>

  <!-- YOUTH FIELDS (EDITABLE) -->

  <div id="formTable">
    <table>
      <tr>
        <td>
          <table>

            <tr>
              <td><label for="youth_gender">Gender</label>:</td>
              <td><%= input('youth', 'gender') %></td>
            </tr>

            <tr>
              <td><label for="youth_birthdate">Birth date</label>:</td>
              <td><%= date_select('youth', 'birthdate', :include_blank => true, :start_year => 1980, :order => [:day, :month, :year]) %></td>
            </tr>

            <tr>
              <td><label for="youth_region">Region</label>:</td>
              <td><%= collection_select(:youth, :region_id, Region.find(:all), :id, :name) %></td>
            </tr>

            <tr>
              <td><label for="youth_yls_score">YLS-score</label>:</td>
              <td><%= text_field('youth', 'yls_score', :size => 2) %></td>
            </tr>



            <tr>
              <td><label for="youth_status">Status</label>:</td>
              <td><%= collection_select(:youth, :youth_status_id, YouthStatus.find(:all), :id, :name) %></td>
            </tr>

            <tr>
              <td><label for="youth_group">Group</label>:</td>
              <td><%= collection_select(:youth, :youth_group_id, YouthGroup.find(:all), :id, :name) %></td>
            </tr>

            <tr>
              <td><label for="youth_institution">Institution</label>:</td>
              <td><%= collection_select(:youth, :institution_id, Institution.find(:all), :id, :name, :include_blank => true) %></td>
            </tr>

            <tr>
              <td><label for="institution_placement_date">Institution placement date</label>:</td>
              <td><%= date_select('youth', 'institution_placement_date', :include_blank => true, :start_year => 2009, :order => [:day, :month, :year]) %></td>
            </tr>
            
            <tr>
              <td><label for="data_collector">Data collector</label>:</td>
              <td><%= collection_select(:youth, :data_collector_id, DataCollector.find(:all), :id, :name) %></td>
            </tr>

            
          </table>

        </td>

        <td valign="bottom">
          <label for="youth_comment">Comment</label>:<br />
          <%= text_area('youth', 'comment', :rows => 10) %>
        </td>
      </tr>
    </table>

  </div>



  <%= submit_tag "Update" %>

  <% if !flash[:saved].nil? %>
    <div id="statusSavedText">
      <%= flash[:saved] %>
    </div>
  <% end %>
<% end %> <!-- END FORM TAG -->

<!-- TABLE OF NOTES RELATED TO YOUTH -->
<h2>Notes</h2>

<div id="resultSet">
  <table>
    <tr>
      <th>Date</th>
      <th>Signature</th>
      <th>Note</th>
    </tr>


    <% @notes.each do |n| %>
      <tr class="<%= get_next_result_set_type %>">
        <td><%= n.created_at.strftime("%Y-%m-%d") %></td>
        <td><%= n.signature %></td>
        <td class="big"><%= n.note %> <%= link_to '[edit]', {:controller => 'youth_note', :action => 'edit', :id => n.id} %></td>
      </tr>
    <% end %>
  </table>
</div>


<p align="right"><%= link_to 'Add new note', {:controller => 'youth_note', :action => 'new', :youth_id => @youth.id} %></p>



<!-- TABLE OF DATA COLLECTIONS -->
<h2>Data Collections</h2>


<div id="resultSet">
  <table>
    <tr>
      <th>Target date</th>
      <th>Type</th>
      <th>Status</th>
    </tr>

    <% type = "odd" %>
    <% @data_collections.each do |dc| %>
      <% if type == "even" %>
        <% type = "odd" %>
      <% else %>
        <% type = "even" %>
      <% end %>

      <tr class="<%= type %>">
        <td><%= dc.target_date %></td>
        <td><%= link_to dc.data_collection_type.name, :controller => 'data_collection', :action => 'edit', :id => dc.id %></td>
        <td><%= dc.calculate_status %></td>
      </tr>
    <% end %>
  </table>
</div>


<div id="rightAlign">
  <%= link_to 'Create data collection', {:controller => 'data_collection', :action => 'new', :youth_id => @youth.id} %>
</div>


